﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using Danser_Control.Managers;
using Danser_Entity.Entities;
using Danser_Entity.Queries.Filters;

namespace Danser_AJAXEnabledWebApplication.DataSourceManagers
{
    /// <summary>
    /// Contains Data Source support methods for the Test Info entities
    /// </summary>
    public class TestInfoDataSourceManager
    {
        #region Memebers:

        /// <summary>
        /// Local list. holds a copy of the table's records in DB,
        /// + maybe 1 more empty record representing a new row in datagrid
        /// </summary>
        private IList<TestInfo> _tests;

        /// <summary>
        /// Control layer interface to access the DB
        /// </summary>
        private IQueryManager manager;

        #endregion

        #region C'tor:

        /// <summary>
        /// creates a TestInfoDataSourceManager instance
        /// </summary>
        public TestInfoDataSourceManager()
        {
            //Get users from proper control interface
            manager = ManagerFactory.QueryManager();
            _tests = manager.GetTests(null);
        }

        #endregion

        #region Query Methods:

        /// <summary>
        /// SELECT method implementation
        /// </summary>
        /// <param name="filter">filter used in WHERE clause</param>
        /// <returns>list of tests info</returns>
        public IList<TestInfo> GetTests(String filter)
        {
            if (!String.IsNullOrEmpty(filter))
            {
                _tests = manager.GetTests(filter);
            }
            //else - get them all
            return _tests;
        }

        #endregion
    }
}
